{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[101 102 103 104]\n",
      " [105 106 107 108]\n",
      " [109 110 111 112]]\n",
      "[ 9 10 11 12]\n",
      "[ 4  8 12]\n",
      "6.5\n",
      "11.916666666666666\n",
      "[ 1  2  3  4  5  6  7  8  9 10 11 12]\n",
      "[[ 1  5  9]\n",
      " [ 2  6 10]\n",
      " [ 3  7 11]\n",
      " [ 4  8 12]]\n",
      "[1 2 3 4 5 6]\n",
      "[[1]\n",
      " [2]\n",
      " [3]\n",
      " [4]\n",
      " [5]\n",
      " [6]]\n",
      "[ 1  2  3  4  5  6  7  8  9 10 11 12]\n",
      "2\n",
      "[[ 1  2  3]\n",
      " [ 5  6  7]\n",
      " [ 9 10 11]]\n",
      "-7.105427357600985e-15\n",
      "[ 6 11]\n",
      "21\n",
      "(array([13.55075847,  0.74003145, -3.29078992]), array([[-0.17622017, -0.96677403, -0.53373322],\n",
      "       [-0.435951  ,  0.2053623 , -0.64324848],\n",
      "       [-0.88254925,  0.15223105,  0.54896288]]))\n",
      "32\n",
      "32\n",
      "[[2 5]\n",
      " [3 7]]\n",
      "[[2 5]\n",
      " [3 7]]\n",
      "[[1 3]\n",
      " [1 4]]\n",
      "[[1.00000000e+00 0.00000000e+00]\n",
      " [1.11022302e-16 1.00000000e+00]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "matrix = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])\n",
    "matrix.shape\n",
    "matrix.size\n",
    "matrix.ndim\n",
    "add_100 = lambda i: i + 100\n",
    "vectorized_add_100 = np.vectorize(add_100)\n",
    "m100 = vectorized_add_100(matrix)\n",
    "print(m100)\n",
    "mxmax = np.max(matrix, axis=0)\n",
    "print(mxmax)\n",
    "mymax = np.max(matrix, axis=1)\n",
    "print(mymax)\n",
    "mmean = np.mean(matrix)\n",
    "print(mmean)\n",
    "mvar = np.var(matrix)\n",
    "print(mvar)\n",
    "mstd = np.std(matrix)\n",
    "mrstd = np.mean(matrix, axis=0)\n",
    "m2x6 = matrix.reshape(2,6)\n",
    "m1 = matrix.reshape(1,-1)\n",
    "print(matrix.reshape(12))\n",
    "print(matrix.T)\n",
    "print(np.array([1, 2, 3, 4, 5, 6]).T)\n",
    "print(np.array([[1, 2, 3, 4, 5, 6]]).T)\n",
    "print(matrix.flatten())\n",
    "print(np.linalg.matrix_rank(matrix))\n",
    "print(matrix[:,:3])\n",
    "print(np.linalg.det(matrix[:,:3]))\n",
    "print(matrix[:,1:].diagonal(offset=-1))\n",
    "print(matrix[:,1:].trace())\n",
    "sm = np.array([[1,-1,3],[1,1,6],[3,8,9]])\n",
    "print(np.linalg.eig(sm))\n",
    "va = np.array([1,2,3])\n",
    "vb = np.array([4,5,6])\n",
    "print(np.dot(va,vb))\n",
    "print(va @ vb)\n",
    "ma = np.array([[1,1],[1,2]])\n",
    "mb = np.array([[1,3],[1,2]])\n",
    "print(np.dot(ma,mb))\n",
    "print(ma @ mb)\n",
    "print(ma * mb)\n",
    "mc = np.array([[1,4],[2,5]])\n",
    "print(mc @ np.linalg.inv(mc))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
